//
//  ActionTo.swift
//  CooperSwift_Example
//
//  Created by 计海峰 on 2021/5/24.
//  Copyright © 2021 CocoaPods. All rights reserved.
//

import Foundation
import UIKit

private struct AssociateKeys {
    static var infoKey: Void?
}


protocol BindToProtocol : NSObjectProtocol {
    func bindTo(_ info: Any?) -> Void
}

extension BindToProtocol {
    var info: Any? {
        get {
            return objc_getAssociatedObject(self, &AssociateKeys.infoKey)
        }
        set {
            objc_setAssociatedObject(self, &AssociateKeys.infoKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
    }
}

extension UITableViewCell : BindToProtocol {
    
    @objc func bindTo(_ info: Any?) {
        guard let info = info else { return }
        self.info = info
    }
    
}
